package com.ly.maven05.model.testDouble;

/**
 * 在该例子中包含了两个协作类：Engine 和 Route，还有一个间接使用者：Directions
 *
 * 站在 Car 的视角，用测试替身替换Engine和Route，用伪实现替换Route，那么就完全控制了向Car提供的各种 directions
 * Created by ly on 2018/3/11.
 */
public class Car {
    private Engine engine;
    public Car(Engine engine) {
        this.engine = engine;
    }

    public void start() {
        this.engine.startUp();
    }

    public void stop() {
        this.engine.shutDown();
    }

    public void drive(Route route) {
        for(Directions direction : route.directions()) {
            direction.follow();
        }
    }
}
